<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="vue2.0.js"></script>
    <script src="vue-router.js"></script>

    <style>
        .router-link-active{
            font-size: 20px;
            color: #00ee00;
        }
    </style>
</head>

<body>
<div id="box">
    <div>
        <router-link to="/home">主页</router-link>
        <router-link to="/news">新闻</router-link>
    </div>
    <div>
        <router-view></router-view>
    </div>
</div>


<script>
    //组件
    var Home = {
        template:'<h3>我是主页</h3>'
    }

    var News = {
        template:'<h3>我是新闻</h3>'
    }

    //配置路由
    var routes=[
        {path:'/home',component:Home},
        {path:'/news',component:News},
        {path:'*',redirect:'/home'}
    ]

    //生成路由实例

    var router =new VueRouter({
        routes :routes
    })

    //将路由挂载在vue实例上

    new Vue({
        el:'#box',
        router:router
    })

</script>
</body>
</html>



















